<?php

/*
 * 投递器,执行router下的信息.
 * and open the template in the editor.
 */
class Dispatcher
{
    
    static public function dispatch($router)
    {
        global $_G;
        $ctrl=  ucfirst($router->getControll());
      
        if(!file_exists(ROOT."/core/Control/$ctrl.php"))
        {
            $ctrl='Basecontroll';
            $action='page404';
            Debugshow::show("控制器或方法不存在!");
            
        }
        else
        {
          $action=$router->getAction();
       
        }
        
        $pars=$router->getParams();  
        $obj=new $ctrl();
        $obj->setParams($pars);
        if(!method_exists($obj,$action))
        {
            Debugshow::show("{$action}方法不存在!");
            $action='page404';
        }
        $_G["web"]["controll"]= $router->getControll();
        $_G["web"]["action"]= $router->getAction();
        $obj->$action();
       
        
    }
}
?>
